home *** CD-ROM | disk | FTP | other *** search
- Path: news.gate.net!pslfl2-35
- From: bhutto@gate.net (William Hutto)
- Newsgroups: comp.lang.c
- Subject: Re: ** Array problem **
- Date: 21 Jan 1996 12:36:49 GMT
- Organization: CyberGate, Inc.
- Message-ID: <4dtc11$21r4@news.gate.net>
- References: <4dqh8k$ov9@neptunus.pi.net>
- NNTP-Posting-Host: pslfl2-35.gate.net
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
- bhutto@gate.net (William Hutto) spake:
- ;In article <4dqh8k$ov9@neptunus.pi.net>, mv@pi.net spake:
- ;;
- ;;Hello Bill Wendlig (and everybody else),
- <snip>
-
- ;;char *s;
- ;;char a[20][20];
- <snip>
-
- ;; for (i=0; i<=15; i++)
- ;; {
- ;; strcpy(a[i],s);
- ;
- ;sizeof a[i] = 20, so:
- ;
- ;22-20 = 2 characters written to a[i+1] which on the last iteration will write
- ;2 characters beyond the end of *a* (illegally).
-
- I should elaborate on this. If i==19, which would be the last array in *a*, it
- would write beyond *a*. The loop above luckily ends before then.
-
- Bill
-
- "Whatcha got on?...Your mind?"
-